package com.share.auth.controller;

import com.share.auth.service.H5LoginService;
import com.share.common.core.context.SecurityContextHolder;
import com.share.common.core.domain.R;
import com.share.common.core.utils.bean.BeanUtils;
import com.share.common.core.web.controller.BaseController;
import com.share.common.core.web.domain.AjaxResult;
import com.share.common.security.annotation.RequiresLogin;
import com.share.common.security.service.TokenService;
import com.share.system.api.model.LoginUser;
import com.share.user.api.domain.UserInfo;
import com.share.user.api.domain.UserVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class H5TokenController extends BaseController {

    @Autowired
    private H5LoginService h5LoginService;

    @Autowired
    private TokenService tokenService;

    @GetMapping("/h5/login/{code}")
    public R<?> login(@PathVariable String code)
    {
        // 用户登录
        LoginUser userInfo = h5LoginService.login(code);
        // 获取登录token
        return R.ok(tokenService.createToken(userInfo));
    }




}
